Skip to content

MemoizingMRUCache class

Defined in

Namespace: Splat Assembly: Splat.Logging.dll Full name: Splat.MemoizingMRUCache<T1, T2> Modifiers: public sealed

Summary

View source

Represents a memoizing Most-Recently-Used (MRU) cache.

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Remarks

This cache memoizes a calculation function: given the same key, it returns the cached value without recomputing. Because the cache assumes memoization, the calculation function should be a "pure" function in the mathematical sense: the same key must always map to the same value for the cache to be correct.

Thread-safety: all structural mutations of the dictionary and MRU list are synchronized via a single gate. The cache intentionally does not attempt to be lock-free because dictionary and MRU list updates must be coordinated.

Constructors

NameSummary
.ctorInitializes a new instance of the [MemoizingMRUCache](# class.

Methods

NameSummary
GetGets the cached value for key, computing and caching it if necessary.
TryGetAttempts to get the cached value without computing it.
InvalidateEnsures that the next time this key is queried, the calculation function will be called.
InvalidateAllInvalidates all items in the cache.
CachedValuesReturns a snapshot of all values currently in the cache.
Inherited members